﻿using System.Windows;
using System.Windows.Controls;

namespace SamizdatSearch.ConditionTree
{
  public static class DragHelper
  {
    public static readonly DependencyProperty DropPositionProperty =
      DependencyProperty.RegisterAttached(
        "DropPosition",
        typeof(DropLocationPosition),
        typeof(DragHelper),
        new FrameworkPropertyMetadata(DropLocationPosition.None)
        );

    public static void SetDropPosition(TreeViewItem item, DropLocationPosition value)
    {
      item.SetValue(DropPositionProperty, value);
    }
    public static DropLocationPosition GetDropPosition(TreeViewItem elementName)
    {
      return (DropLocationPosition)elementName.GetValue(DropPositionProperty);
    }

    public static readonly DependencyProperty IsDraggedObjectProperty =
      DependencyProperty.RegisterAttached(
        "IsDraggedObject",
        typeof (bool),
        typeof (DragHelper),
        new PropertyMetadata(false)
        );

    public static void SetIsDraggedObject(TreeViewItem item, bool value)
    {
      item.SetValue(IsDraggedObjectProperty, value);
    }

    public static bool GetIsDraggedObject(TreeViewItem item)
    {
      return (bool) item.GetValue(IsDraggedObjectProperty);
    }

    public static readonly DependencyProperty IsDropTargetProperty =
      DependencyProperty.RegisterAttached(
        "IsDropTarget",
        typeof (bool),
        typeof (DragHelper),
        new PropertyMetadata(false)
        );

    public static void SetIsDropTarget(TreeViewItem item, bool value)
    {
      item.SetValue(IsDropTargetProperty, value);
    }

    public static bool GetIsDropTarget(TreeViewItem item)
    {
      return (bool) item.GetValue(IsDropTargetProperty);
    }
  }
}